package com.mys.dxc;

public class StopThread {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		StopRunner runner = new StopRunner();
		Thread t = new Thread(runner);
		System.out.println(t.getState());
		t.start();
		try {
			Thread.sleep(1000);
			System.out.println(t.getState());
		} catch (InterruptedException e) {
			
			e.printStackTrace();
		}
		t.interrupt();
		System.out.println(t.getState());
		System.out.println("main over");
		
	}

}

class StopRunner implements Runnable{
	//private boolean flag = true;
	@Override
	public void run() {
		int i = 0;
		while(!Thread.currentThread().isInterrupted()){
			System.out.println(i++);
		}
		
	}
	
//	public void stop(){
//		flag = false;
//	}
//	
}
